<?php
// +----------------------------------------------------------------------
// | PHP [ JUST YOU ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2017 http://www.jyphp.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: FlyingPig <flyingpigfp@163.com>
// +----------------------------------------------------------------------

namespace App\Http\Controllers;


use App\Logic\ClubLogic;

class Club extends Base
{

    /**
     * @api 创建个人俱乐部
     * @param name
     * @return mixed
     */
    public function create()
    {
        ClubLogic::instance()->createLogic($this->param['name'], $this->uid);
        return $this->returnData();
    }


    /**
     * @api 修改俱乐部名称
     * @param name
     * @param club_id
     * @return mixed
     */
    public function updateClubName()
    {
        return $this->returnData(
            ClubLogic::instance()->updateClubNameLogic($this->param['club_id'], $this->uid, $this->param['name'])
        );
    }

    /**
     * @api 请求加入俱乐部
     * @param club_id
     * @param desc
     * @return mixed
     */
    public function joinIn()
    {
        return $this->returnData(
            ClubLogic::instance()->joinInLogic($this->param['club_id'], $this->uid, $this->param['desc'])
        );
    }


    /**
     * @api 查看俱乐部列表
     * @return mixed
     */
    public function table()
    {
        return $this->returnData(ClubLogic::instance()->tableLogic($this->uid));
    }

    /**
     * @api 根据俱乐部id进行筛选
     * @return mixed
     */
    public function checkClub()
    {
        return $this->returnData(ClubLogic::instance()->checkClub($this->param));
    }


    /**
     * @api 某俱乐部成员列表
     * @param club_id
     * @return mixed
     */
    public function member()
    {
        return $this->returnData(ClubLogic::instance()->memberLogic($this->param['club_id'],$this->uid));
    }


    /**
     * @api 查看某个俱乐部的加入请求
     * @param club_id
     * @return mixed
     */
    public function requestList()
    {
        return $this->returnData(ClubLogic::instance()->requestListLogic($this->param['club_id']));
    }


    /**
     * @api 处理申请加入俱乐部
     * @param user_id
     * @param club_id
     * @param status
     * @return mixed
     */
    public function handleRequest()
    {
        return $this->returnData(
            ClubLogic::instance()->handleRequestLogic($this->param['user_id'], $this->param['club_id'], $this->param['status'])
        );
    }

    /**
     * @api 退出俱乐部
     * @param club_id
     * @param user_id
     * @return mixed
     */
    public function exitClub()
    {
        return $this->returnData(
            ClubLogic::instance()->exitClubLogic(
               $this->uid,
               empty($this->param['user_id']) ? 0 : $this->param['user_id'],
               $this->param['club_id']
            )
        );
    }


    /**
     * @api 解散俱乐部
     * @param club_id
     * @return mixed
     */
    public function dissolve()
    {
        return $this->returnData(ClubLogic::instance()->dissolveLogic($this->uid, $this->param['club_id']));
    }


    /**
     * @api 获取俱乐部的所有房间信息
     * @return mixed
     */
    public function room()
    {
        return $this->returnData(ClubLogic::instance()->roomLogic($this->param['club_id']));
    }


}